#!/bin/sh

source ./projects-list.sh


function build_config() {
	local project=$1
	local trueprj=$(ls ../bundle | grep -i $project-[0-9master])
	if [ -z "$trueprj" ]; then
		echo "project : $project config error"
	else
		echo "
{
	\"dir\": [\"../../bundle/$trueprj\"],
	\"filter\": {
		\"unfold\": true
	}
}
" > configs/$project.json
	fi
}

if [ $# -gt 0 ]; then
	for arg in $@; do
		build_config $arg
	done
	exit 0
fi

for index in ${!initprojects[@]}; do
	build_config ${initprojects[$index]}
done

for index in ${!projects[@]}; do
	build_config ${projects[$index]}
done
